
<script>
function Play (file) {
	var path = '<embed src="' + file + '" autostart="true" loop="false" hidden="true" height="0" width="0">';
	document.getElementById (file).innerHTML = path + '<img src="images/stop.png" style="cursor:pointer;" onclick="Stop(' + "'" + file + "'" + ')">';
}
function Stop (file) {
document.getElementById (file).innerHTML = '<img src="images/play.jpg" style="cursor:pointer;" onclick="Play(' + "'" + file + "'" + ')">';
}
</script>	
<?php

require_once("util/scraper.php"); 

class musicplayer {
    function __construct() {
        $this->m_currentSong = 1;
		
		// filling dummy values
		$this->m_musiclist = array("song1","song2","song3");
		
		
    }
	
    // public methods
    public function loadPlayList($artist, $album) {
        echo "<br/>Loading playlist for $artist & $album...";
		$type = 'Scraper';
		$obj = new $type;
		
		$url = "http://musicmp3.ru/artist_" . $artist . "__album_" . $album . ".html";
		//$url = "http://musicmp3.ru/artist_red-hot-chili-peppers__album_californication.html";
		//echo "$url";
        $start = "Play(this,'";
        $end = '\'';
        $offset = '<th>Track</th>';
        $max = 100;
        
        $obj->initialize($url,$start, $end, $offset, $max );
        
        if($obj->searchForData()){
    		echo "<br/>Succes!";
			$this->m_musiclist = $obj->getResultList();
			//print_r($this->m_musiclist);
		}
		else{
			echo "<br/>musicophaling gefaald";
		}
    }
	
	public function playSong($id){
		$songUrl = $this->m_musiclist[$id];
		echo "<div id=\"$songUrl\"><img src=\"images/play.jpg\" style=\"cursor:pointer;\" onclick=\"Play('$songUrl')\"></div>";

	}
	
	// private member variables
	private $m_musiclist;
	private $m_currentSong;
	private $m_testSongURI;
}

?>